﻿@model List<RoadQualityEvalAPI.Models.TripStatsModel>

@{
    Layout = null;
    var totalTrips = Model.Count;
}

<script type="text/javascript">

    $('.falseTripStatsRemove').on('click', function (evt) {


        evt.preventDefault();
        evt.stopPropagation();

        //alert("Clicked");
        console.log('clicked');
        url = $(this).data('url');

        $.get(url, function (data) {

            alert("All false trip stats have been removed!");
            location.reload();

        });

    });

</script>

<h4>General statistics:</h4>
<hr />
<div id="general_stats">

    <div class="row">
        <p>General info regarding trip statistics, averages, etc.</p>
    </div>

    <div class="row">
        @Html.Label("Total trips: " + totalTrips)
    </div>


    <div class="row">
        <button data-url='@Url.Action("RemoveFalseTripStats", "Admin")' class="falseTripStatsRemove">Remove false trip stats</button>  
    </div>

    <div class="row">

        <table class="customTable">
            <tr>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().CreatedAt)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().Info)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripDistance)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripDurationMillis)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripAverageSpeed)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripAverageRoughness)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripNoOfPotholes)
                </th>
                <th>
                    @Html.DisplayNameFor(m => m.FirstOrDefault().TripNoOfSpeedbumps)
                </th>
            </tr>

            @foreach (var trip in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(m => trip.CreatedAt)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.Info)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripDistance)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripDurationMillis)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripAverageSpeed)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripAverageRoughness)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripNoOfPotholes)
                    </td>
                    <td>
                        @Html.DisplayFor(m => trip.TripNoOfSpeedbumps)
                    </td>
                </tr>
            }

        </table>

    </div>


</div>

